<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "https://github.com/rbatis/rbatis_sql/raw/main/mybatis-3-mapper.dtd">
<mapper>
    <select id="findGoodsCategoryList" >
        select t.* from (
		select 
        category_id, category_level, parent_id, category_name, category_rank, is_deleted, 
    create_time, create_user, update_time, update_user
	
        from tb_newbee_mall_goods_category
        <where>
            <if test="params.categoryLevel!=null && params.categoryLevel!=''">
                and category_level = #{params.categoryLevel}
            </if>
            <if test="params.parentId!=null && params.parentId!=''">
                and parent_id = #{params.parentId}
            </if>
            and is_deleted = 0
        </where>
        ) t
            order by t.category_rank desc
        <if test="params.start!=null && params.limit!=null">
            limit #{params.start},#{params.limit}
        </if>
    </select>
    <select id="getTotalGoodsCategories">
        select count(*) from tb_newbee_mall_goods_category
        <where>
            <if test="params.categoryLevel!=null && params.categoryLevel!=''">
                and category_level = #{params.categoryLevel}
            </if>
            <if test="params.parentId!=null && params.parentId!=''">
                and parent_id = #{params.parentId}
            </if>
            and is_deleted = 0
        </where>
    </select>
</mapper>